package com.sc.admin.test.controller;

import lombok.extern.log4j.Log4j2;
import org.springframework.stereotype.Controller;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.RequestMapping;
import com.sc.admin.test.service.IAdministratorsService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RequestParam;
import com.sc.core.util.DataAutoSearch.DataAutoSearch;
import java.util.List;
import java.util.Map;
import com.sc.common.response.Response;
import com.sc.admin.test.AdministratorsEntity;
import java.util.ArrayList;

/**
 * 管理员控制器
 */
@Controller
@Log4j2
@AllArgsConstructor
@RequestMapping("/admin-test/administrators")
public class AdministratorsController {

    private final IAdministratorsService administratorsService;


    @GetMapping("list")
    public String list(Model model){
        return "test/administrators/list";
    }


    @GetMapping("list-data")
    @ResponseBody
    public Response<List<AdministratorsEntity>> listData(@RequestParam Map<String, Object> searchDTO){
        List<AdministratorsEntity> list = administratorsService.getList(new DataAutoSearch(searchDTO));
        return Response.success(list);
    }


    @GetMapping("get-enum-map")
    @ResponseBody
    public Response<List<Map<String, Object>>> getEnumMap(@RequestParam("name") String name){
        List<Map<String, Object>> enumMap = new ArrayList<>();
        if (name.equals("status")) {
            enumMap = AdministratorsEntity.Status.getEnumList();
        }

        return Response.success(enumMap);
    }
}